home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Franz PD / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].zip / Franz PD Disk #047 (1990)(Amiga User Group Deutschland e.V.)[v Disaster Master 2].adf / A68K_Beispiele / Lissajous.asm < prev    next >
Assembly Source File  |  1989-07-02  |  13KB  |  492 lines

  1. ************************************************************************
  2. *                                                                      *
  3. * These are simply Lissajous figures which you can create using an     *
  4. * oscilloscope and two frequency generators.                           *
  5. * The definition is:                                                   *
  6. *                     x(t)=sin(u*t)                                    *
  7. *                     y(t)=sin(v*t+p)                                  *
  8. *                                                                      *
  9. * u is the angular frequency in the x direction                        *
  10. * v is the angular frequency in the y direction                        *
  11. * p is the phase difference between x and y                            *
  12. *                                                                      *
  13. * This implementation was written by:                                  *
  14. * E. Lenz                                                              *
  15. * Johann-Fichte-Strasse 11                                             *
  16. * 8 Munich 40                                                          *
  17. * Germany                                                              *
  18. *                                                                      *
  19. ************************************************************************
  20.  
  21.       XREF GetReal,RealOut,request
  22.  
  23. _AbsExecBase        equ 4
  24.  
  25. **** exec *****
  26.  
  27. _LVOForbid       equ -$84
  28. _LVOPermit       equ -$8a
  29. _LVOGetMsg       equ -$174
  30. _LVOReplyMsg     equ -$17a
  31. _LVOWaitPort     equ -$180
  32. _LVOCloseLibrary equ -$19e
  33. _LVOOpenLibrary  equ -$228
  34.  
  35. **** intuition ******
  36.  
  37. _LVOClearMenuStrip equ -$36
  38. _LVOCloseWindow    equ -$48
  39. _LVOOpenWindow     equ -$cc
  40. _LVOSetMenuStrip   equ -$108
  41.  
  42. ***** graphics ******
  43.  
  44. _LVOMove            equ -$f0
  45. _LVODraw            equ -$f6
  46. _LVORectFill        equ -$132
  47. _LVOSetAPen         equ -$156
  48.  
  49. *** mathffp ***
  50.  
  51. _LVOSPFix  equ -$1e
  52. _LVOSPAdd  equ -$42
  53. _LVOSPMul  equ -$4e
  54.  
  55. *** mathtrans ***
  56.  
  57. _LVOSPSin equ -$24
  58.  
  59. wd_RPort         equ $32
  60. wd_UserPort      equ $56
  61. pr_MsgPort       equ $5c
  62. pr_CLI           equ $ac
  63. ThisTask         equ $114
  64. VBlankFrequency  equ $212
  65.  
  66. hund3  equ $96000049  300
  67. hund   equ $b4000047  90
  68. hund1  equ $f0000047  120
  69. dt     equ $a3d70b3a  0.01
  70.  
  71.        movea.l _AbsExecBase,a6   test if WB or CLI
  72.        movea.l ThisTask(a6),a0
  73.        tst.l   pr_CLI(a0)
  74.        bne.s   isCLI
  75.  
  76.        lea     pr_MsgPort(a0),a0 for WB get WB Message
  77.        jsr     _LVOWaitPort(a6)
  78.        jsr     _LVOGetMsg(a6)
  79.        move.l  d0,WBenchMsg
  80.  
  81. isCLI  cmpi.b  #60,VBlankFrequency(a6) test if PAL or NTSC
  82.        beq.s   isNTSC
  83.        move.w  #256,nw+6
  84.        move.l  #hund1,NTSC+2
  85.  
  86. isNTSC lea     GfxName(pc),a1        open graphics library
  87.        moveq   #0,d0
  88.        jsr     _LVOOpenLibrary(a6)
  89.        move.l  d0,GfxBase
  90.        beq.s   Gexit
  91.  
  92.        lea     IntName(pc),a1        open intuition library
  93.        moveq   #0,d0
  94.        jsr     _LVOOpenLibrary(a6)
  95.        move.l  d0,IntBase
  96.        beq.s   Gexit
  97.  
  98.        lea     MathName(pc),a1       open mathffp library
  99.        moveq   #0,d0
  100.        jsr     _LVOOpenLibrary(a6)
  101.        move.l  d0,MathBase
  102.        beq.s   Gexit
  103.  
  104.        lea     MtransName(pc),a1     open mathtrans library
  105.        moveq   #0,d0
  106.        jsr     _LVOOpenLibrary(a6)
  107.        move.l  d0,MtransBase
  108.        bne.s   Trok
  109.        lea     MtransName(pc),a0   first line
  110.        movem.l a4-a5,-(a7)
  111.        lea     notfnd(pc),a1     second line
  112.        suba.l  a2,a2             no third line
  113.        lea     hdtxt(pc),a3      header
  114.        lea     OkTxt(pc),a4      gadget text
  115.        suba.l  a5,a5             no 2nd gadget
  116.        jsr     request
  117.        movem.l (a7)+,a4-a5
  118. Gexit  bra     exit
  119.  
  120. Trok   lea     nw(pc),a0             open window
  121.        movea.l IntBase(pc),a6
  122.        jsr     _LVOOpenWindow(a6)
  123.        move.l  d0,window
  124.        beq.s   Gexit
  125.       
  126.  
  127. ; Set menu
  128.  
  129.        movea.l d0,a0           which window
  130.        lea     Menu1(pc),a1    which menu
  131.        jsr     _LVOSetMenuStrip(a6)
  132.  
  133.        movea.l window(pc),a0
  134.        movea.l wd_RPort(a0),a5
  135.  
  136. redraw movea.l GfxBase(pc),a6  clear screen
  137.        moveq   #0,d0
  138.        movea.l a5,a1
  139.        jsr     _LVOSetAPen(a6)
  140.  
  141.        movea.l a5,a1
  142.        moveq   #0,d0
  143.        moveq   #0,d1
  144.        move.l  #640,d2
  145.        move.l  #250,d3
  146.        jsr     _LVORectFill(a6)
  147.  
  148.        movea.l a5,a1
  149.        moveq   #3,d0
  150.        jsr     _LVOSetAPen(a6)
  151.  
  152.        clr.l   t
  153.  
  154. draw   bsr     print
  155.  
  156. wait   bsr     trycls
  157.        beq.s   draw
  158.        cmpi.l  #$200,d7
  159.        beq.s   exit
  160.  
  161.        cmpi.l  #$100,d7
  162.        bne.s   wait
  163.  
  164. ; Choice from menu
  165.  
  166.        movea.l window(pc),a0
  167.        movea.l $5e(a0),a0   Load Window.MessageKey
  168.        move.w  $18(a0),d0   Load message code
  169.        move.w  d0,d1
  170.        andi.w  #$f,d1
  171.        bne.s   draw
  172.  
  173.        andi.w  #$f0,d0      Menu 1
  174.        bne.s   menu12       Submenu 1
  175.        bsr     xfreq
  176. sedraw bra.s   redraw
  177.  
  178. menu12 cmpi.w  #$20,d0      Submenu 2
  179.        bne.s   menu13
  180.        bsr     yfreq
  181.        bra.s   redraw
  182.  
  183. menu13 cmpi.w  #$40,d0      Submenu 3
  184.        bne.s   draw
  185.        bsr     phase
  186.        bra.s   sedraw
  187.  
  188. exit   movea.l IntBase(pc),a6
  189.        move.l  window(pc),d0
  190.        beq.s   noWin
  191.        movea.l d0,a0
  192.        jsr     _LVOClearMenuStrip(a6) Clear menu
  193.        movea.l window(pc),a0
  194.        jsr     _LVOCloseWindow(a6)    close window
  195.  
  196. noWin  movea.l _AbsExecBase,a6
  197.        tst.l   WBenchMsg
  198.        beq.s   NoBenh
  199.        jsr     _LVOForbid(a6)       reply to WB
  200.        movea.l WBenchMsg(pc),a1
  201.        jsr     _LVOReplyMsg(a6)
  202.        jsr     _LVOPermit(a6)
  203.  
  204. NoBenh move.l  MtransBase(pc),d1     close mathtrans library
  205.        beq.s   noMtr
  206.        movea.l d1,a1
  207.        jsr     _LVOCloseLibrary(a6)
  208.  
  209. noMtr  move.l  MathBase(pc),d1      close mathffp library
  210.        beq.s   noMath
  211.        movea.l d1,a1
  212.        jsr     _LVOCloseLibrary(a6)
  213.  
  214. noMath move.l  IntBase(pc),d1       close intuition library
  215.        beq.s   noInt
  216.        movea.l d1,a1
  217.        jsr     _LVOCloseLibrary(a6)
  218.  
  219. noInt  move.l  GfxBase(pc),d1       close graphics library
  220.        beq.s   noGfx
  221.        movea.l d1,a1
  222.        jsr     _LVOCloseLibrary(a6)
  223.  
  224. noGfx  moveq   #0,d0                no error
  225.        rts
  226.  
  227. trycls movem.l d0-d6/a0-a6,-(a7)
  228.        movea.l _AbsExecBase,a6
  229.        moveq   #0,d7
  230.        movea.l window(pc),a0
  231.        movea.l wd_UserPort(a0),a0  load Window.UserPort
  232.        jsr     _LVOGetMsg(a6)
  233.        tst.l   d0
  234.        beq.s   noMsg1         No message
  235.  
  236.        movea.l d0,a1
  237.        move.l  $14(a1),d7       Message in d7
  238.        jsr     _LVOReplyMsg(a6) Always reply
  239.  
  240. noMsg1 movem.l (a7)+,d0-d6/a0-a6
  241. noMsg  tst.l   d7
  242.        rts
  243.  
  244. print  movea.l MathBase(pc),a6
  245.        movea.l MtransBase(pc),a4
  246.        move.l  t(pc),d0
  247.        move.l  #dt,d1
  248.        jsr     _LVOSPAdd(a6)
  249.        move.l  d0,t
  250.         
  251.        move.l  d0,d1
  252.        move.l  u(pc),d0
  253.        jsr     _LVOSPMul(a6)
  254.  
  255.        exg     a4,a6
  256.        jsr     _LVOSPSin(a6)
  257.  
  258.        exg     a4,a6
  259.        move.l  #hund3,d1
  260.        jsr     _LVOSPMul(a6)
  261.        move.l  #hund3,d1
  262.        jsr     _LVOSPAdd(a6)
  263.        jsr     _LVOSPFix(a6)
  264.        move.l  d0,d7
  265.  
  266.        move.l  v(pc),d0
  267.        move.l  t(pc),d1
  268.        jsr     _LVOSPMul(a6)
  269.        move.l  p(pc),d1
  270.        jsr     _LVOSPAdd(a6)
  271.  
  272.        exg     a4,a6
  273.        jsr     _LVOSPSin(a6)
  274.  
  275.        exg     a4,a6
  276. NTSC   move.l  #hund,d5
  277.        move.l  d5,d1
  278.        jsr     _LVOSPMul(a6)
  279.        move.l  d5,d1
  280.        jsr     _LVOSPAdd(a6)
  281.        jsr     _LVOSPFix(a6)
  282.        move.l  d0,d6
  283.  
  284.        move.l  d0,d1
  285.        move.l  d7,d0
  286.        movea.l GfxBase(pc),a6
  287.        movea.l a5,a1
  288.        jsr     _LVOMove(a6)
  289.  
  290.        move.l  d6,d1
  291.        move.l  d7,d0
  292.        movea.l a5,a1
  293.        jsr     _LVODraw(a6)
  294.        rts
  295.  
  296.  
  297. xfreq  bsr.s   uout
  298.        moveq   #18,d0
  299.        lea     tu(pc),a0
  300.        jsr     GetReal
  301.        tst.l   d1
  302.        bne.s   nogo
  303.        move.l  d0,u
  304.        rts
  305.  
  306. yfreq  bsr.s   vout
  307.        moveq   #18,d0
  308.        lea     tv(pc),a0
  309.        jsr     GetReal
  310.        tst.l   d1
  311.        bne.s   nogo
  312.        move.l  d0,v
  313. nogo   rts
  314.  
  315. phase  bsr.s   pout
  316.        moveq   #18,d0
  317.        lea     tp(pc),a0
  318.        jsr     GetReal
  319.        tst.l   d1
  320.        bne.s   nogo
  321.        move.l  d0,p
  322.        rts
  323.  
  324. uout   lea     uval(pc),a0
  325.        move.l  u(pc),d0
  326.        bra.s   outout
  327.  
  328. vout   lea     vval(pc),a0
  329.        move.l  v(pc),d0
  330.        bra.s   outout
  331.  
  332. pout   lea     pval(pc),a0
  333.        move.l  p(pc),d0
  334. outout moveq   #2,d1
  335.        moveq   #9,d2
  336.        movea.l a0,a1
  337. remove move.b  #' ',(a1)+
  338.        dbra    d2,remove
  339.        jsr     RealOut
  340.        rts
  341.  
  342. tu     dc.b  'X freq ='
  343. uval   dc.b  '          '
  344. tv     dc.b  'Y freq ='
  345. vval   dc.b  '          '
  346. tp     dc.b  'P phase='
  347. pval   dc.b  '          '
  348.  
  349. u      dc.l $80000041     1
  350. v      dc.l $86666642     2.1
  351. t      dc.l 0
  352. p      dc.l 0
  353.  
  354. WBenchMsg   dc.l 0
  355. MtransBase  dc.l 0
  356. MathBase    dc.l 0
  357. DosBase     dc.l 0
  358. GfxBase     dc.l 0
  359. IntBase     dc.l 0
  360.  
  361. window      dc.l 0
  362.  
  363. ; requester texts
  364.  
  365. notfnd      dc.b ' not found',0
  366. hdtxt       dc.b ' Lissajous Request',0
  367. OkTxt       dc.b ' OK',0
  368.             even
  369.  
  370. DosName     dc.b 'dos.library',0
  371.             even
  372.  
  373. MtransName  dc.b 'mathtrans.library',0
  374.             even
  375.  
  376. MathName    dc.b 'mathffp.library',0
  377.             even
  378.  
  379. GfxName     dc.b 'graphics.library',0
  380.             even
  381.  
  382. IntName     dc.b 'intuition.library',0
  383.             even
  384.  
  385. title       dc.b  'Lissajous figures',0
  386.             even
  387.  
  388. ***** Window definition *****
  389.  
  390. nw          dc.w 0,0         Position left,top
  391.             dc.w 640,199     Size width,height
  392.             dc.b 0,1         Colors detail-,block pen
  393.             dc.l $340        IDCMP-Flags
  394.             dc.l $140f       Window flags
  395.             dc.l 0           ^Gadget
  396.             dc.l 0           ^Menu check
  397.             dc.l title       ^Window name
  398. nws         dc.l 0           ^Screen structure,
  399.             dc.l 0           ^BitMap
  400.             dc.w 100         MinWidth
  401.             dc.w 40          MinHeight
  402.             dc.w -1          MaxWidth
  403.             dc.w -1,1        MaxHeight,Screen type
  404.  
  405. **** menu definition ****
  406.  
  407. Menu1       dc.l 0           Next menu
  408.             dc.w 50,0        Position left edge,top edge
  409.             dc.w 100,20      Dimensions width,height
  410.             dc.w 1           Menu enabled
  411.             dc.l mtext1      Text for menu header
  412.             dc.l item11      ^First in chain
  413.             dc.l 0,0         Internal
  414.  
  415. mtext1      dc.b 'parameters',0
  416.             even
  417.  
  418. item11      dc.l item12      next in chained list
  419.             dc.w 0,0         Position left edge,top edge
  420.             dc.w 170,10      Dimensions width,height
  421.             dc.w $52         itemtext+highcomp+itemenabled
  422.             dc.l 0           Mutual exclude
  423.             dc.l I11txt      Pointer to intuition text
  424.             dc.l 0
  425.             dc.b 0,0
  426.             dc.l 0
  427.             dc.w 0
  428.  
  429.  
  430. I11txt      dc.b 0           Front pen  (blue)
  431.             dc.b 1           Back pen   (white)
  432.             dc.b 0,0         Draw mode
  433.             dc.w 0           Left edge
  434.             dc.w 0           Top edge
  435.             dc.l 0           Text font
  436.             dc.l item11txt   Pointer to text
  437.             dc.l 0           Next text
  438.  
  439. item11txt   dc.b 'u angular frequency x',0
  440.             even
  441.  
  442. item12      dc.l item13      next in chained list
  443.             dc.w 0,10        Position left edge,top edge
  444.             dc.w 170,10      Dimensions width,height
  445.             dc.w $52         itemtext+highcomp+itemenabled
  446.             dc.l 0           Mutual exclude
  447.             dc.l I12txt      Pointer to intuition text
  448.             dc.l 0
  449.             dc.b 0,0
  450.             dc.l 0
  451.             dc.w 0
  452.  
  453.  
  454. I12txt      dc.b 0           Front pen  (blue)
  455.             dc.b 1           Back pen   (white)
  456.             dc.b 0,0         Draw mode
  457.             dc.w 0           Left edge
  458.             dc.w 0           Top edge
  459.             dc.l 0           Text font
  460.             dc.l item12txt   Pointer to text
  461.             dc.l 0           Next text
  462.  
  463. item12txt   dc.b 'v angular frequency y',0
  464.             even
  465.  
  466. item13      dc.l 0           next in chained list
  467.             dc.w 0,20        Position left edge,top edge
  468.             dc.w 170,10      Dimensions width,height
  469.             dc.w $52         itemtext+highcomp+itemenabled
  470.             dc.l 0           Mutual exclude
  471.             dc.l I13txt      Pointer to intuition text
  472.             dc.l 0
  473.             dc.b 0,0
  474.             dc.l 0
  475.             dc.w 0
  476.  
  477.  
  478. I13txt      dc.b 0           Front pen  (blue)
  479.             dc.b 1           Back pen   (white)
  480.             dc.b 0,0         Draw mode
  481.             dc.w 0           Left edge
  482.             dc.w 0           Top edge
  483.             dc.l 0           Text font
  484.             dc.l item13txt   Pointer to text
  485.             dc.l 0           Next text
  486.  
  487. item13txt   dc.b 'p phase difference',0
  488.             even
  489.  
  490.             end
  491.  
  492.